1 package controllers
.actions
;
3 import javax
.swing
.undo
.AbstractUndoableEdit
;
5 import models
.GraphEdge
;
6 import models
.GraphVertex
;
9 public class DeleteNode
extends AbstractUndoableEdit
{
10 private static final long serialVersionUID
= -7929100929760152271L;
11 private GraphVertex o
;
12 private SelectionController selectionController
;
13 private GraphEdge
[] affectedEdges
;
15 public DeleteNode(SelectionController selectionController
)
17 this.selectionController
= selectionController
;
18 this.o
= selectionController
.getSelectedVertex();
22 private void removeAffectedEdges()
24 selectionController
.getModel().removeEdge(affectedEdges
);
27 private void addAffectedEdges()
29 selectionController
.getModel().addEdge(affectedEdges
);
32 private void getAffectedEdges(){
33 GraphEdge
[] arr
= selectionController
.getModel().getEdges();
35 for(int i
=0; i
< arr
.length
; i
++)
38 affectedEdges
= new GraphEdge
[count
];
40 for(int i
=0; i
< arr
.length
; i
++)
42 affectedEdges
[count
++] = arr
[i
];
45 private void redoAction()
48 removeAffectedEdges();
49 selectionController
.removeSelected();
50 selectionController
.getModel().removeGraph(o
);
63 selectionController
.getModel().addGraph(o
);
64 selectionController
.setSelected(o
);
66 public boolean isSignificant(){
70 public String
getPresentationName(){
71 return "Vertex verwijderen.";